<?php

require FCPATH . '/application/controllers/frontend.php';

class Service extends Frontend {

    public function __construct() {
	parent::__construct();
    }

    public function index() {
	$this->load->model(array('service_model', 'slide_show_model'));
	$lang = $this->get_language();
	$id = intval($this->uri->segment(3, 1));

	$columns = array(
	    'category',
	    array('title_' . $lang, 'title'),
	    array('content_' . $lang, 'content')
	);
	$conditions = array(array('where', 'id', $id));
	$records = $this->service_model->records($columns, $conditions);
	if (count($records) > 0) {
	    $record = $records[0];
	} else {
	    die('404');
	}

	$columns = array(
	    'link', array('description_' . $lang, 'description'), array('n.name', 'image_name')
	);
	$conditions = array(
	    array('where', 'type', 3),
	    array('where', 'parent', $id)
	);
	$slide_shows = $this->slide_show_model->records($columns, $conditions);

	$this->load_css('frontend_service_index');
	$this->load_js(array('lib', 'frontend_service_index'));
	$this->rend('service_index', array(
	    'record' => $record,
	    'slide_shows' => $slide_shows,
	    'menus' => array('urban_planning','architecture_desion','landscape_design','tourism_and_resorts','consulting','real_estate','governement','commercial'),
	    'index' => $id - 1,
	    'id' => $id
	));
    }

    public function show() {
	$this->load_css('frontend_service_show');
	$this->load_js(array('lib', 'frontend_service_show'));
	$this->rend('service_show');
    }
}